package Application.serviceImpl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import Application.dao.RecordDao;
import Application.dao.SignDao;
import Application.entity.Record;
import Application.entity.Result;
import Application.entity.Sign;
import Application.service.RecordService;
@Service("RecordService")
public class RecordServiceImpl implements RecordService {

	@Resource
	private RecordDao dao;

	@Resource
	private SignDao signdao;

	@Override
	public Result insertRecord(Record record) {
		Result r = new Result();
		try {
			Sign sign = signdao.getSignByCourse(record);
			if (sign.getSign()==record.getSign()) {
				dao.insertRecord(record);
				r.setContent(1);
			} else {
				r.setContent(0);
			}
		} catch (Exception e) {
			r.setContent(0);
		}
		return r;
	}

	@Override
	public List<Record> findRecords(Record record) {
		return dao.getRecordsByCourse(record);
	}

}
